//
//  QLViewController.m
//  QLCustomCamera
//
//  Created by 李强LiQ on 08/29/2020.
//  Copyright (c) 2020 李强LiQ. All rights reserved.
//

#import "QLViewController.h"
#import "QLPhotoViewController.h"
#import "QLRecordParam.h"
#import "QLRecordManager.h"

@interface QLViewController ()<QLRecordManagerDelegate>

@end

@implementation QLViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    UIButton *setBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    setBtn.frame = CGRectMake(0, 180, QL_SCREEN_WIDTH, 40);
    [setBtn setTitle:@"设置" forState:UIControlStateNormal];
    setBtn.titleLabel.font = [UIFont systemFontOfSize:17];
    [setBtn setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
    [setBtn addTarget:self action:@selector(setClick) forControlEvents:UIControlEventTouchUpInside];
    setBtn.backgroundColor = [UIColor yellowColor];
    [self.view addSubview:setBtn];
}

-(void)setClick
{
    QLRecordParam *param = [QLRecordParam recordConfigWithVideoRatio:QLShootRatioFullScreen shootMode:photoVideoMode position:AVCaptureDevicePositionBack maxRecordTime:15.0f minRecordTime:1.0f isCompression:NO waterMark:nil isFilter:YES isShowBeautyBtn:YES isShowAlbumBtn:YES currentVC:self];
    [QLRecordManager shareManager].recordParam = param;
    [QLRecordManager shareManager].delegate = self;
    QLPhotoViewController *page = [QLPhotoViewController new];
    page.modalPresentationStyle  = UIModalPresentationFullScreen;
    [self presentViewController:page animated:YES completion:^{}];
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

//MARK:NLRecordManagerDelegate
-(void)getTakenPhoto:(UIImage *)photo{
    dispatch_async(dispatch_get_main_queue(), ^{
//        [self requestAddPhotos:@[photo].mutableCopy];
        NSLog(@"扽到照片");
    });
}
//-(void)getVideoData:(NSData *)outputData dataURL:(NSURL *)outputURL coverURL:(NSURL *)coverURL coverImage:(UIImage *)coverImage recordTime:(CGFloat)recordTime

-(void)getVideoData:(NSData *)outputData dataUrl:(NSURL *)outputUrl coverUrl:(NSURL *)coverUrl coverImage:(UIImage *)coverImage
{
    dispatch_async(dispatch_get_main_queue(), ^{
        NSLog(@"dedao 视频");
//        [self requestAddVideoCoverImg:coverImage videoDuration:(long)round(recordTime) videoData:outputData videoPath:outputURL.absoluteString];
    });
}

@end
